from django.conf.urls.defaults import *
from django.contrib.auth.views import *
from azure_learning.accounts.views import register, profile
from azure_learning.resources.views import *
from azure_learning.taxonomy.views import *
from azure_learning.themes.views import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

from themes.views import *

urlpatterns = patterns(
    '',
    ( r'^accounts/login/$', login, { 'template_name': 'accounts/login.html' } ),
    ( r'^accounts/register/$', register ),
    ( r'^accounts/profile/$', profile ),
    #(r'^accounts/logout/$', logout),
    ( r'^accounts/logout/$', logout_then_login ),
    
    #Resources
    ( r'^resources/add/$', addResource, { 'template_name':  'resources/add_resource.html' } ),
    ( r'^resources/search/$', searchResource, { 'template_name':  'resources/search_resource.html' } ),
    ( r'^resource/(\d+)/$', showResource, { 'template_name':  'resources/show_resource.html' } ),
    ( r'^resource/diggResource/(\d+)/(\-*\d+)/$', diggResource, { 'template_name':  'resources/show_resource.html' } ),
    #Taxonomy
    ( r'^category/add/$', addCategory, { 'template_name': 'taxonomy/add_category.html' } ),
    ( r'^category/show/$', showCategories, { 'template_name': 'taxonomy/show_categories.html' } ),
    ( r'^category/showtree/$', showCategoryTree, { 'template_name': 'taxonomy/show_tree.html' } ),
    ( r'^tag/add/$', addTag, { 'template_name': 'taxonomy/add_tag.html' } ),
    ( r'^admin/', include( admin.site.urls ) ),
    url( r'^theme/add/$', add_theme, name = 'add_theme' ),
    url( r'^theme/(?P<theme_id>\d+)/$', show_theme, name = 'theme_detail' ),
    url( r'^theme/(?P<theme_id>\d+)/edit$', edit_theme, name = 'edit_theme' ),

    # Topic
    url( r'^theme/(?P<theme_id>\d+)/topic/(?P<topic_id>\d+)/$', show_topic, name = 'topic') ,
    url( r'^theme/(?P<theme_id>\d+)/topic/add/$', add_post, { 'topic_id': None }, name = 'add_topic' ),

    # Post
    url( r'^theme/topic/(?P<topic_id>\d+)/post/add/$', add_post, name = 'add_post' ),
    url( r'^theme/post/(?P<post_id>\d+)/$', show_post, name='post'),
    #url('^post/(?P<post_id>\d+)/edit/$', edit_post, name='edit_post'),
    #url('^post/(?P<post_id>\d+)/delete/$', delete_post, name='delete_post'),

)
